package br.com.Servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import br.com.Dao.EnderecoDao;
import br.com.Modelo.Endereco;

/**
 * Servlet implementation class cad_endereco
 */
@WebServlet("/admin/cad_endereco")
public class cad_endereco extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public cad_endereco() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	System.out.print(request.getParameter("id_end")+"pagina"+request.getParameter("id_pagina")+""+request.getParameter("cep"));
		
		Endereco end = new Endereco();
		
		end.setCep(request.getParameter("cep"));
		end.setCidade(request.getParameter("cidade"));
		end.setBairro(request.getParameter("bairro"));
		end.setNumero(Integer.parseInt(request.getParameter("numero")));
		end.setCount(2);
		end.setRua(request.getParameter("rua"));
		end.setIdPagina(Integer.parseInt(request.getParameter("id_pagina")));
		end.setTelefone(request.getParameter("telefone"));
		
		EnderecoDao dao = new EnderecoDao();
		
		dao.adiciona(end);	
		
		
		response.sendRedirect("/plataforma_marketing/admin/admin_loja.jsp");
	}

}
